﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OverStore.CompositeIdentifiers;

namespace OverStore.TutorialAsTest.UnitTest.Components.MulitpartKeys
{
    [TestClass]
    public class KeysTest
    {
        [TestMethod]
        public void Key2Equality()
        {
            var k1 = new Key2<int, int>(2.As("One"), 3.As("Two"));
            var k2 = new Key2<int, int>(2.As("One"), 3.As("Two"));
            var k3 = new Key2<int, int>(2.As("One1"), 3.As("Two1"));
            var k4 = KeyHelper.MultipartKey(3.As("One"), 3.As("Two"));

            Assert.AreEqual(k1, k2);
            Assert.AreNotEqual(k1, k3);
            Assert.AreNotEqual(k1, k4);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void Key2NonUniqueName()
        {
            var k1 = new Key2<int, int>(2.As("One"), 3.As("One"));
        }       
    }
}
